ostree/ot-builtin-checkout.c \
ostree/ot-builtin-commit.c \
ostree/ot-builtin-compose.c \
+ ostree/ot-builtin-diff.c \
ostree/ot-builtin-fsck.c \
ostree/ot-builtin-init.c \
ostree/ot-builtin-log.c \
g_clear_object (&root_info);
return ret;
}
+
+gboolean
+ostree_repo_diff (OstreeRepo *self,
+ const char *ref,
+ GFile *target,
+ GPtrArray **out_modified,
+ GPtrArray **out_removed,
+ GPtrArray **out_added,
+ GCancellable *cancellable,
+ GError **error)
+{
+ gboolean ret = FALSE;
+ GPtrArray *ret_modified = NULL;
+ GPtrArray *ret_removed = NULL;
+ GPtrArray *ret_added = NULL;
+
+ g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
+ "Not implemented yet");
+ goto out;
+
+ ret = TRUE;
+ out:
+ if (ret_modified)
+ g_ptr_array_free (ret_modified, TRUE);
+ if (ret_removed)
+ g_ptr_array_free (ret_removed, TRUE);
+ if (ret_added)
+ g_ptr_array_free (ret_added, TRUE);
+ return ret;
+}
GCancellable *cancellable,
GError **error);
+typedef struct {
+ guint content_differs : 1;
+ guint xattrs_differs : 1;
+ guint unused : 30;
+
+ GFileInfo *src_info;
+ GFileInfo *target_info;
+
+ char *src_file_checksum;
+ char *target_file_checksum;
+
+ GVariant *src_xattrs;
+ GVariant *target_xattrs;
+} OstreeRepoDiffItem;
+
+gboolean ostree_repo_diff (OstreeRepo *self,
+ const char *ref,
+ GFile *target,
+ GPtrArray **out_modified, /* OstreeRepoDiffItem */
+ GPtrArray **out_removed, /* OstreeRepoDiffItem */
+ GPtrArray **out_added, /* OstreeRepoDiffItem */
+ GCancellable *cancellable,
+ GError **error);
+
typedef void (*OstreeRepoObjectIter) (OstreeRepo *self, const char *path,
GFileInfo *fileinfo, gpointer user_data);
static OstreeBuiltin builtins[] = {
{ "checkout", ostree_builtin_checkout, 0 },
+ { "diff", ostree_builtin_diff, 0 },
{ "init", ostree_builtin_init, 0 },
{ "commit", ostree_builtin_commit, 0 },
{ "compose", ostree_builtin_compose, 0 },
--- /dev/null
+/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
+ *
+ * Copyright (C) 2011 Colin Walters <walters@verbum.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * Author: Colin Walters <walters@verbum.org>
+ */
+
+#include "config.h"
+
+#include "ot-builtins.h"
+#include "ostree.h"
+
+#include <glib/gi18n.h>
+
+static GOptionEntry options[] = {
+ { NULL }
+};
+
+gboolean
+ostree_builtin_diff (int argc, char **argv, const char *repo_path, GError **error)
+{
+ GOptionContext *context;
+ gboolean ret = FALSE;
+ OstreeRepo *repo = NULL;
+ const char *target;
+ const char *rev;
+ GFile *targetf = NULL;
+ GPtrArray *modified = NULL;
+ GPtrArray *removed = NULL;
+ GPtrArray *added = NULL;
+
+ context = g_option_context_new ("REV TARGETDIR - Compare directory TARGETDIR against revision REV");
+ g_option_context_add_main_entries (context, options, NULL);
+
+ if (!g_option_context_parse (context, &argc, &argv, error))
+ goto out;
+
+ repo = ostree_repo_new (repo_path);
+ if (!ostree_repo_check (repo, error))
+ goto out;
+
+ if (argc < 3)
+ {
+ gchar *help = g_option_context_get_help (context, TRUE, NULL);
+ g_printerr ("%s\n", help);
+ g_free (help);
+ g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+ "REV and TARGETDIR must be specified");
+ goto out;
+ }
+
+ rev = argv[1];
+ target = argv[2];
+ targetf = ot_util_new_file_for_path (target);
+
+ if (!ostree_repo_diff (repo, rev, targetf, &modified, &removed, &added, NULL, error))
+ goto out;
+
+ ret = TRUE;
+ out:
+ g_clear_object (&repo);
+ g_clear_object (&targetf);
+ if (modified)
+ g_ptr_array_free (modified, TRUE);
+ if (removed)
+ g_ptr_array_free (removed, TRUE);
+ if (added)
+ g_ptr_array_free (added, TRUE);
+ return ret;
+}
gboolean ostree_builtin_checkout (int argc, char **argv, const char *repo, GError **error);
gboolean ostree_builtin_commit (int argc, char **argv, const char *repo, GError **error);
gboolean ostree_builtin_compose (int argc, char **argv, const char *repo, GError **error);
+gboolean ostree_builtin_diff (int argc, char **argv, const char *repo, GError **error);
gboolean ostree_builtin_init (int argc, char **argv, const char *repo, GError **error);
gboolean ostree_builtin_log (int argc, char **argv, const char *repo, GError **error);
gboolean ostree_builtin_pull (int argc, char **argv, const char *repo, GError **error);